<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="com.saltfish.appengine.worktable.datastore.Work"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.Set"%>
<%@page import="java.util.TreeMap"%>

<%
	request.setCharacterEncoding("UTF-8");
	String title = (String)request.getAttribute("title");
	Work work = (Work)request.getAttribute("work");
	String selYm = (String)request.getAttribute("selYm");
%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title><%=title%></title>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
	<link rel="apple-touch-icon" href="/images/calendar.png"> 
	<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.css" />
	<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
	<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.js"></script>
	<script>
<!--
		$(document).ready(function(){
			if ($("#holiday")[0].selectedIndex == 1) {
				$('#starttime').selectmenu('disable');
				$('#endtime').selectmenu('disable');
				$('#breaktime').selectmenu('disable');
			};
			var holiday = $("#holiday").bind("change", function(){
			    if(holiday != $(this).val()){
			        holiday = $(this).val();
			        console.log("val change to " + holiday);
			        if (holiday == 'on') {
			        	$('select').selectmenu('disable');
			        } else {
			        	$('select').selectmenu('enable');
			        }
			    }
			 }).val();
		});
-->		
	</script>     
</head>
<body>
    <div data-role="page" id="page_edit" >
        <div data-role="header" data-theme="a" data-position="inline">
            <h1><%=work.getYmdByJp()%></h1>
         	<a href="/worktable?selYm=<%=selYm%>" data-role="button">戻る</a>
        </div>
     	<form method="POST" action="/admin/register">
        <div data-role="content">
			<div data-role="fieldcontain">
				<label for="starttime" class="select">出勤時間</label>
				<select name="starttime" id="starttime">
<%
		Map<String, String> map = (Map<String, String>)request.getAttribute("startTimeList");
		Set<String> keys =map.keySet();
		for (String key : keys) {
			String value = map.get(key);
%>
					<option value="<%=key%>" <%=value%>><%=key%></option>
<%}%>
				</select>
			</div>
			<div data-role="fieldcontain">
				<label for="endtime" class="select">退勤時間</label>
				<select name="endtime" id="endtime">
<%
		map = (Map<String, String>)request.getAttribute("endTimeList");
		keys = map.keySet();
		for (String key : keys) {
			String value = map.get(key);
%>
					<option value="<%=key%>" <%=value%>><%=key%></option>
<%}%>
				</select>
			</div>
			<div data-role="fieldcontain">
				<label for="breaktime" class="select">休憩時間</label>
				<select name="breaktime" id="breaktime">
<%
		map = (Map<String, String>)request.getAttribute("breakTimeList");
		keys =map.keySet();
		for (String key : keys) {
			String value = map.get(key);
%>
					<option value="<%=key%>" <%=value%>><%=key%></option>
<%}%>
				</select>
			</div>
 			<div data-role="fieldcontain">
				<label for="holiday" class="select">休日</label>
				<select name="holiday" id="holiday" data-role="slider">
                	<option value="off" <%=work.getHolidayOff()%>>Off</option>
                	<option value="on" <%=work.getHolidayOn()%>>On</option>
				</select>
			</div>
            <div data-role="fieldcontain" >      
                <label for="comment">メモ</label>
                <textarea cols="40" rows="4" name="comment" id="comment"><%=work.getComment()%></textarea>
            </div>
            <div data-role="fieldcontain" >      
				<input type="submit" name="submit" id="submit" data-theme="a" value="保存" />
            </div>
            <input type="hidden" name="id" id="id" value="<%=work.getId()%>" />
            <input type="hidden" name="selYm" id="selYm" value="<%=selYm%>" />
        </div>
        </form>
    </div>
</body>
</html>